package com.boot.unity.api.modules.train.controller;

import com.boot.unity.api.modules.train.dto.StudentDTO;
import com.boot.unity.api.modules.train.entity.Student;
import com.boot.unity.api.modules.train.result.Result;
import com.boot.unity.api.modules.train.service.StudentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@Api(tags = "无纸化-保存报名信息及状态")
@RestController
@RequestMapping("/api/students")
@AllArgsConstructor
public class StudentController {
    private final StudentService studentService;

    //@ApiOperation(value = "保存")
    //@PostMapping
    public Result save(@RequestBody Student student) {
        return studentService.save(student);
    }

//    @GetMapping("/{id}")
//    @ApiOperation(value = "根据id获取")
//    public Student get(@PathVariable Long id) {
//        return studentDao.getById(id);
//    }
//
    @ApiOperation(value = "修改")
    @PutMapping
    public Result update(@RequestBody StudentDTO studentDTO) {
        return studentService.update(studentDTO);
    }
//
//    @GetMapping
//    @ApiOperation(value = "列表")
//    public PageTableResponse list(PageTableRequest tableRequest) {
//        return new PageTableHandler(
//            request -> studentDao.count(request.getParams()),
//            request -> studentDao.list(request.getParams(), request.getOffset(), request.getLimit())
//        ).handle(tableRequest);
//    }
//
//    @DeleteMapping("/{id}")
//    @ApiOperation(value = "删除")
//    public void delete(@PathVariable Long id) {
//        studentDao.delete(id);
//    }

    //@ApiOperation(value = "查询最新10条数据")
    //@GetMapping(value = "/list")
    public Result list(){
        return studentService.listLatest10();
    }
}
